//extern  PFNGLGENBUFFERSPROC                  glGenBuffers; 

//no functions extensions
void InitGLExtensions()
{
	debug::add("");

	if(sys::isExtensionSupported("GL_ARB_shadow")!=0)
	debug::Log<<"GL_ARB_shadow exists"<<std::endl;
	else
	debug::Log<<"GL_ARB_shadow not exists"<<std::endl;

	if(sys::isExtensionSupported("GL_ARB_shadow_ambient")!=0)
	debug::Log<<"GL_ARB_shadow_ambient exists"<<std::endl;
	else
	debug::Log<<"GL_ARB_shadow_ambient not exists"<<std::endl;

	if(sys::isExtensionSupported("GL_ARB_vertex_shader")!=0)
	debug::Log<<"GL_ARB_vertex_shader exists"<<std::endl;
	else
	debug::Log<<"GL_ARB_vertex_shader not exists"<<std::endl;

	if(sys::isExtensionSupported("GL_ARB_fragment_shader")!=0)
	debug::Log<<"GL_ARB_fragment_shader exists"<<std::endl;
	else
	debug::Log<<"GL_ARB_fragment_shader not exists"<<std::endl;

	if(sys::isExtensionSupported("GL_ARB_shader_objects")!=0)
	debug::Log<<"GL_ARB_shader_objects exists"<<std::endl;
	else
	debug::Log<<"GL_ARB_shader_objects not exists"<<std::endl;

	if(sys::isExtensionSupported("GL_ARB_shading_language_100")!=0)
	debug::Log<<"GL_ARB_shading_language_100 exists"<<std::endl;
	else
	debug::Log<<"GL_ARB_shading_language_100 not exists"<<std::endl;

	if(sys::isExtensionSupported("GL_EXT_gpu_shader4")!=0)
	debug::Log<<"GL_EXT_gpu_shader4 exists"<<std::endl;
	else
	debug::Log<<"GL_EXT_gpu_shader4 not exists"<<std::endl;

	if(sys::isExtensionSupported("GL_EXT_geometry_shader4")!=0)
	{
		SFC.AddFute("geometry_shaders",1);
	//	bla-bla-bla;
		debug::Log<<"GL_EXT_geometry_shader4 exists"<<std::endl;
	}
	else
	debug::Log<<"GL_EXT_geometry_shader4 not exists"<<std::endl;

	debug::add("");


	//gl init

	glTexImage3D = (PFNGLTEXIMAGE3DPROC) sys::glGetExtensionAddress( "glTexImage3D" );

	glGenBuffers = (PFNGLGENBUFFERSARBPROC) sys::glGetExtensionAddress( "glGenBuffers" );

	glBindBuffer = (PFNGLBINDBUFFERARBPROC) sys::glGetExtensionAddress ( "glBindBuffer" );

	glBufferData = (PFNGLBUFFERDATAARBPROC) sys::glGetExtensionAddress ( "glBufferData" );

	glDeleteBuffers = (PFNGLDELETEBUFFERSARBPROC) sys::glGetExtensionAddress ( "glDeleteBuffers" );

	glBufferSubData = (PFNGLBUFFERSUBDATAARBPROC)sys::glGetExtensionAddress ( "glBufferSubData" );

	glMapBuffer = (PFNGLMAPBUFFERARBPROC)sys::glGetExtensionAddress ( "glMapBuffer" );

	glUnmapBuffer = (PFNGLUNMAPBUFFERARBPROC)sys::glGetExtensionAddress ( "glUnmapBuffer" );

	glDrawRangeElements = (PFNGLDRAWRANGEELEMENTSPROC) sys::glGetExtensionAddress ( "glDrawRangeElements" );

	glCompressedTexImage2D = (PFNGLCOMPRESSEDTEXIMAGE2DPROC)sys::glGetExtensionAddress ("glCompressedTexImage2D");
	if (glCompressedTexImage2D!=NULL)
		SFC.AddFute("texture_compressing");

	glDrawArraysInstanced=(PFNGLDRAWARRAYSINSTANCEDEXTPROC)sys::glGetExtensionAddress ( "glDrawArraysInstanced" );

	glDrawElementsInstanced=(PFNGLDRAWELEMENTSINSTANCEDEXTPROC)sys::glGetExtensionAddress ( "glDrawElementsInstanced" );
	if (glDrawElementsInstanced!=NULL)
		SFC.AddFute("instansing");

	glMultiTexCoord1f = (PFNGLMULTITEXCOORD1FARBPROC)sys::glGetExtensionAddress ( "glMultiTexCoord1f" );

	glMultiTexCoord2f = (PFNGLMULTITEXCOORD2FARBPROC)sys::glGetExtensionAddress ( "glMultiTexCoord2f" );
	
	glMultiTexCoord3f = (PFNGLMULTITEXCOORD3FVARBPROC)sys::glGetExtensionAddress ( "glMultiTexCoord3f" );
	
	glClientActiveTexture = (PFNGLCLIENTACTIVETEXTUREPROC)sys::glGetExtensionAddress ( "glClientActiveTexture" );

	glSampleCoverage = (PFNGLSAMPLECOVERAGEPROC)sys::glGetExtensionAddress ( "glSampleCoverage" );

	glActiveTexture=(PFNGLACTIVETEXTUREPROC)sys::glGetExtensionAddress ("glActiveTexture");



	 glWeightfv = (PFNGLWEIGHTFVARBPROC)sys::glGetExtensionAddress ("glWeightfv");
	 glWeightPointer = (PFNGLWEIGHTPOINTERARBPROC)sys::glGetExtensionAddress ("glWeightPointer");
	 glVertexBlend = (PFNGLVERTEXBLENDARBPROC)sys::glGetExtensionAddress ("glVertexBlend");

	 glCurrentPaletteMatrix = (PFNGLCURRENTPALETTEMATRIXARBPROC)sys::glGetExtensionAddress ("glCurrentPaletteMatrix");
	 glMatrixIndexubv = (PFNGLMATRIXINDEXUBVARBPROC)sys::glGetExtensionAddress ("glMatrixIndexubv");
	 glMatrixIndexusv = (PFNGLMATRIXINDEXUSVARBPROC)sys::glGetExtensionAddress ("glMatrixIndexusv");
	 glMatrixIndexPointer = (PFNGLMATRIXINDEXPOINTERARBPROC)sys::glGetExtensionAddress ("glMatrixIndexPointer");

	glCreateShaderObject=(PFNGLCREATESHADEROBJECTARBPROC)sys::glGetExtensionAddress ( "glCreateShaderObject" );

	if (glCreateShaderObject!=NULL)
	{
		if(sys::isExtensionSupported("GL_EXT_gpu_shader4")!=0)
		{
			SFC.AddFute("shaders",4);
		}
		else
		{
			SFC.AddFute("shaders",1);
		}
	}

	glProgramParameteri = (PFNGLPROGRAMPARAMETERIEXTPROC) sys::glGetExtensionAddress ( "glProgramParameteri" );

	glCreateProgramObject=(PFNGLCREATEPROGRAMOBJECTARBPROC)sys::glGetExtensionAddress ( "glCreateProgramObject" );

	glAttachObject=(PFNGLATTACHOBJECTARBPROC)sys::glGetExtensionAddress ( "glAttachObject" );

	glDetachObject=(PFNGLDETACHOBJECTARBPROC)sys::glGetExtensionAddress ( "glDetachObject" );

	glDeleteObject=(PFNGLDELETEOBJECTARBPROC)sys::glGetExtensionAddress ( "glDeleteObject" );

	glShaderSource=(PFNGLSHADERSOURCEARBPROC)sys::glGetExtensionAddress ( "glShaderSource" );

	glCompileShader=(PFNGLCOMPILESHADERARBPROC)sys::glGetExtensionAddress ( "glCompileShader" );

	glLinkProgram=(PFNGLLINKPROGRAMARBPROC)sys::glGetExtensionAddress ( "glLinkProgram" );

	glValidateProgram=(PFNGLVALIDATEPROGRAMARBPROC)sys::glGetExtensionAddress ( "glValidateProgram" );

	glUseProgramObject=(PFNGLUSEPROGRAMOBJECTARBPROC)sys::glGetExtensionAddress ( "glUseProgramObject" );

	glGetObjectParameteriv=(PFNGLGETOBJECTPARAMETERIVARBPROC)sys::glGetExtensionAddress ( "glGetObjectParameteriv" );

	glGetInfoLog=(PFNGLGETINFOLOGARBPROC)sys::glGetExtensionAddress ( "glGetInfoLog" );

	glUniform1f=(PFNGLUNIFORM1FARBPROC)sys::glGetExtensionAddress ( "glUniform1f" );

	glUniform1i=(PFNGLUNIFORM1IARBPROC)sys::glGetExtensionAddress ( "glUniform1i" );

	glUniform1fv = (PFNGLUNIFORM1FVARBPROC)sys::glGetExtensionAddress ( "glUniform1fv" ) ;

	glUniform2fv = (PFNGLUNIFORM2FVARBPROC)sys::glGetExtensionAddress ( "glUniform2fv" ) ;

	glUniform3fv = (PFNGLUNIFORM3FVARBPROC)sys::glGetExtensionAddress ( "glUniform3fv" ) ;

	glUniform3f = (PFNGLUNIFORM3FARBPROC)sys::glGetExtensionAddress ( "glUniform3f" );

	glUniform4fv = (PFNGLUNIFORM4FVARBPROC)sys::glGetExtensionAddress ( "glUniform4fv" ) ;

	glGetUniformLocation=(PFNGLGETUNIFORMLOCATIONARBPROC)sys::glGetExtensionAddress ( "glGetUniformLocation" );

	glEnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYARBPROC)sys::glGetExtensionAddress ( "glEnableVertexAttribArray" );

	glVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERARBPROC)sys::glGetExtensionAddress ( "glVertexAttribPointer" );

	glDisableVertexAttribArray = (PFNGLDISABLEVERTEXATTRIBARRAYARBPROC)sys::glGetExtensionAddress ( "glDisableVertexAttribArray" );

	glBindAttribLocation = (PFNGLBINDATTRIBLOCATIONARBPROC)sys::glGetExtensionAddress ( "glBindAttribLocation" );

	glGetAttribLocation = (PFNGLGETATTRIBLOCATIONARBPROC)sys::glGetExtensionAddress ( "glGetAttribLocation" );



glGetShaderSource = (PFNGLGETSHADERSOURCEARBPROC)sys::glGetExtensionAddress ( "glGetShaderSource" );

glUniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVARBPROC)sys::glGetExtensionAddress ( "glUniformMatrix4fv" );

glUniformMatrix4x3fv = (PFNGLUNIFORMMATRIX4X3FVARBPROC)sys::glGetExtensionAddress ( "glUniformMatrix4x3fv" );








	glIsRenderbuffer=(PFNGLISRENDERBUFFEREXTPROC)sys::glGetExtensionAddress ( "glIsRenderbuffer" );

	glBindRenderbuffer=(PFNGLBINDRENDERBUFFEREXTPROC)sys::glGetExtensionAddress ( "glBindRenderbuffer" );

	glDeleteRenderbuffers=(PFNGLDELETERENDERBUFFERSEXTPROC)sys::glGetExtensionAddress ( "glDeleteRenderbuffers" );

	glGenRenderbuffers=(PFNGLGENRENDERBUFFERSEXTPROC)sys::glGetExtensionAddress ( "glGenRenderbuffers" );

	glRenderbufferStorage=(PFNGLRENDERBUFFERSTORAGEEXTPROC)sys::glGetExtensionAddress ( "glRenderbufferStorage" );

	glGetRenderbufferParameteriv=(PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC)sys::glGetExtensionAddress ( "glGetRenderbufferParameteriv" );

	glIsFramebuffer=(PFNGLISFRAMEBUFFEREXTPROC)sys::glGetExtensionAddress ( "glIsFramebuffer" );

	glBindFramebuffer=(PFNGLBINDFRAMEBUFFEREXTPROC)sys::glGetExtensionAddress ( "glBindFramebuffer" );

	glDeleteFramebuffers=(PFNGLDELETEFRAMEBUFFERSEXTPROC)sys::glGetExtensionAddress ( "glDeleteFramebuffers" );

	glGenFramebuffers=(PFNGLGENFRAMEBUFFERSEXTPROC)sys::glGetExtensionAddress ( "glGenFramebuffers" );

	glCheckFramebufferStatus=(PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC)sys::glGetExtensionAddress ( "glCheckFramebufferStatus" );

	glFramebufferTexture1D=(PFNGLFRAMEBUFFERTEXTURE1DEXTPROC)sys::glGetExtensionAddress ( "glFramebufferTexture1D" );

	glFramebufferTexture2D=(PFNGLFRAMEBUFFERTEXTURE2DEXTPROC)sys::glGetExtensionAddress ( "glFramebufferTexture2D" );

	glFramebufferTexture3D=(PFNGLFRAMEBUFFERTEXTURE3DEXTPROC)sys::glGetExtensionAddress ( "glFramebufferTexture3D" );

	glFramebufferRenderbuffer=(PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC)sys::glGetExtensionAddress ( "glFramebufferRenderbuffer" );

	glGetFramebufferAttachmentParameteriv=(PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC)sys::glGetExtensionAddress ( "glGetFramebufferAttachmentParameteriv" );

	glGenerateMipmap=(PFNGLGENERATEMIPMAPEXTPROC)sys::glGetExtensionAddress ( "glGenerateMipmap" );

	glDrawBuffers =(PFNGLDRAWBUFFERSPROC)sys::glGetExtensionAddress ( "glDrawBuffers" );

	glRenderbufferStorageMultisample =(PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC)sys::glGetExtensionAddress ( "glRenderbufferStorageMultisample" );

	glPointParameterfv=(PFNGLPOINTPARAMETERFVEXTPROC)sys::glGetExtensionAddress ( "glPointParameterfv" );

	glBlendFuncSeparate = (PFNGLBLENDFUNCSEPARATEEXTPROC)sys::glGetExtensionAddress ( "glBlendFuncSeparate" );

	glBlendEquationSeparate = (PFNGLBLENDEQUATIONSEPARATEEXTPROC)sys::glGetExtensionAddress ( "glBlendEquationSeparate" );

	glBlendEquation = (PFNGLBLENDEQUATIONEXTPROC)sys::glGetExtensionAddress ( "glBlendEquation" );

	glClampColor = (PFNGLCLAMPCOLORARBPROC)sys::glGetExtensionAddress ( "glClampColor" );

	debug::add("");











	//wgl init
	wglSwapInterval=(PFNWGLSWAPINTERVALEXTPROC)wglGetProcAddress ( "wglSwapIntervalEXT" );
	if (wglSwapInterval!=NULL)
	debug::Log<<"wglSwapIntervalEXT init"<<std::endl;
	else
	debug::Log<<"wglSwapIntervalEXTnot init"<<std::endl;

	wglGetSwapInterval=(PFNWGLGETSWAPINTERVALEXTPROC)wglGetProcAddress ( "wglSwapIntervalEXT" );
	if (wglGetSwapInterval!=NULL)
	debug::Log<<"wglGetSwapIntervalEXT init"<<std::endl;
	else
	debug::Log<<"wglGetSwapIntervalEXT not init"<<std::endl;

	wglChoosePixelFormat = (PFNWGLCHOOSEPIXELFORMATARBPROC)wglGetProcAddress("wglChoosePixelFormatARB");
	if (wglChoosePixelFormat!=NULL)
	debug::Log<<"wglChoosePixelFormatARB init"<<std::endl;
	else
	debug::Log<<"wglChoosePixelFormatARB not init"<<std::endl;

	wglCreateContextAttribs = (PFNWGLCREATECONTEXTATTRIBSARBPROC)wglGetProcAddress("wglCreateContextAttribsARB");
	if (wglCreateContextAttribs!=NULL)
	debug::Log<<"wglCreateContextAttribsARB init"<<std::endl;
	else
	debug::Log<<"wglCreateContextAttribsARB not init"<<std::endl;

	debug::add("");


	//detected features of current videocard

	//texture compression
	caps::s3tc_comp = 0;
	caps::fxt1_comp = 0;
	caps::latc_comp = 0;
	caps::rgtc_comp = 0;

	if(sys::isExtensionSupported("GL_S3_s3tc") || sys::isExtensionSupported("GL_EXT_texture_compression_s3tc"))
	{
		caps::s3tc_comp = 1;
		debug::Log<<"s3tc supported!"<<std::endl;
	}

	if(!caps::s3tc_comp)
	{
		if(sys::isExtensionSupported("GL_3DFX_texture_compression_FXT1"))
		{
			caps::fxt1_comp = 1;
			debug::Log<<"fxt1 supported!"<<std::endl;
		}
	}

	if(sys::isExtensionSupported("GL_ARB_texture_compression_rgtc") || sys::isExtensionSupported("GL_EXT_texture_compression_rgtc"))
	{
		caps::rgtc_comp = 1;
		debug::Log<<"rgtc supported (core)!"<<std::endl;
	}

	if(!caps::rgtc_comp)
	{
		if(sys::isExtensionSupported("GL_EXT_texture_compression_latc"))
		{
			caps::latc_comp = 1;
			debug::Log<<"latc supported!"<<std::endl;
		}
	}

}
